package com.example.administrator.myapplication;

        import android.support.v7.app.AppCompatActivity;
        import android.os.Bundle;
        import android.widget.ListView;
        import android.widget.Toast;

        import com.example.administrator.myapplication.adapter.MyAdapter;
        import com.example.administrator.myapplication.bean.Weather;
        import com.example.administrator.myapplication.util.GetJsonDateUtil;
        import com.google.gson.Gson;

        import java.util.List;

public class MainActivity extends AppCompatActivity {

    private ListView listview;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        initData();
        initEvent();
    }
    private void initView(){
        listview = (ListView) findViewById(R.id.listview);

    }
    private void initData(){
        String jsondata= new GetJsonDateUtil().getJson(MainActivity.this,"data.json");
        Gson gson=new Gson();
        Weather weather=gson.fromJson(jsondata,Weather.class);
        String temperature=weather.getResult().getToday().getTemperature();
        Toast.makeText(MainActivity.this, temperature, Toast.LENGTH_SHORT).show();
        List<Weather.ResultBean.FutureBean> futureBeen=weather.getResult().getFuture();
        listview.setAdapter(new MyAdapter(MainActivity.this,futureBeen));
    }
    private void initEvent(){

    }
}
